package com.qf.day15.stream;

import com.qf.day13.doudizhu.PukeCard;
import com.qf.day13.doudizhu.PukeCardUtils;
import com.qf.day14.homework.Puke;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class StreamDemo4 {
    public static void main(String[] args) {
        //去除空串
        //Arrays.aslist出来的集合不可修改,不能删除,增加......
        List<String> list = Arrays.asList("a", "", "b", "c", "", "d", "");
        ArrayList<String> arrayList = new ArrayList<>(list);
        while (arrayList.remove("")){

        }

        //去除空串    过滤集合中的元素stream().filter()留下()
        System.out.println(arrayList);
        List<String> collect = list.stream().filter(x -> x.equals("")).collect(Collectors.toList());
        System.out.println(collect);

        List<PukeCard> pukeList = PukeCardUtils.createPukeList();
        System.out.println(pukeList);
        List<PukeCard> collect1 = pukeList.stream().filter(pukeCard -> pukeCard.getType().equals("♥")).collect(Collectors.toList());
        System.out.println(collect1);

        //产生随机数
        //limit(): 限制 Stream 中的元素数量。
        Random random = new Random();
        random.ints(1,100).limit(10).sorted().forEach(s-> System.out.println(s));


    }
}
